package Chapter01.H20211215;

import java.util.List;
import java.util.Scanner;

/**
 * @author oldliu
 * @since 1.0
 */
public class SubjecTest {
    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        SubjectDao dao=new SubjectDao();
        while (true){
            System.out.println("课程操作：1：查询全部课程信息 2：主键查找单个对象 3：增加 4：删除 5：修改 6：退出");
            int choice=input.nextInt();
            if(choice==1){
                List<Subject> all = dao.findALL();
                for(Subject s:all)
                    System.out.println(s);
            }else if(choice==2){
                Subject subject = dao.get(343333L);
                System.out.println(subject==null?"没有":subject);
            }else if(choice==3){
                System.out.println("请输入课程名：");
                String subjectname=input.next();
                System.out.println("请输入班级号:");
                int classhour=input.nextInt();
                System.out.println("请输入年级号:");
                int gradeid=input.nextInt();
                Subject su=new Subject(subjectname,classhour,gradeid);
                int zhi=dao.add(su);
                System.out.println(zhi);
            }else if(choice==4){
                System.out.println("请输入学号：");
                int id=input.nextInt();
                int zhi=dao.del(id);
                System.out.println(zhi);
            }else if(choice==5){

            }else if(choice==6){
                break;
            }
        }
    }
}
